<template>
    <div>
        <van-field v-model="name" label="名称" placeholder="请输入名称" id="name" />
         <van-button color="linear-gradient(to right, #7232dd, #ffffff)" @click="add" style="width:200px" id="add" >
                修改
        </van-button>
    </div>
</template>

<script>
    export default {
        data(){
            return{
                id:this.$route.query.id,
                name:''
            }
        },
        methods:{
            getcate(){
                this.$axios.get('getcateByid?id='+this.id)
                .then(res=>{
                    this.name=res.data.cate.name
                })
            },
            add(){
                this.$axios.post('cateM',{'name':this.name,id:this.id})
                .then(res=>{
                    if(res.data.code==200){
                        this.$toast.fail('添加成功')
                        this.$router.push('/catelist')
                    }
                    

                }) 
            },
        },
        mounted(){
            this.getcate()
        },
        
    }
</script>

<style scoped>

</style>